<%--
  Created by IntelliJ IDEA.
  User: 联想Y7000
  Date: 2022/9/28
  Time: 19:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>查询所有</title>
</head>
<body>
<input type="button" value="新增" id="add"><br>
<hr>
<table border="1" cellspacing="0" width="90%">
    <tr>
        <th>序号</th>
        <th>品牌名称</th>
        <th>企业名称</th>
        <th>排序</th>
        <th>品牌介绍</th>
        <th>状态</th>
        <th>操作</th>
    </tr>

    <c:forEach items="${brands}" var="brand" varStatus="status">
        <tr align="center">
                <%--<td>${brand.id}</td>--%>
            <td>${status.count}</td>
            <td>${brand.brandName}</td>
            <td>${brand.companyName}</td>
            <td>${brand.ordered}</td>
            <td>${brand.description}</td>
            <c:if test="${brand.status == 1}">
                <td>启用</td>
            </c:if>
            <c:if test="${brand.status == 0}">
                <td>禁用</td>
            </c:if>
                <%--<td><a href="/brand-demo/selectByIdServlet?id=${brand.id}">修改</a> <a href="#">删除</a></td>--%>
            <td><input type="button" value="修改" id="update${brand.id}"> <input type="button" value="删除"
                                                                               id="delete${brand.id}"></td>
        </tr>
        <script>
            document.getElementById("update${brand.id}").onclick = function () {
                location.href = "/brand-demo/selectByIdServlet?id=${brand.id}";
            }
            document.getElementById("delete${brand.id}").onclick = function () {
                if (window.confirm("确认删除？")) {
                    location.href = "/brand-demo/deleteByIdServlet?id=${brand.id}";
                }
            }
        </script>
    </c:forEach>
</table>
<hr>
<c:forEach begin="1" end="10" step="1" var="i">
    <a href="#">${i}</a>
</c:forEach>

<script>
    document.getElementById("add").onclick = function () {
        location.href = "/brand-demo/addBrand.jsp";
    }
</script>
</body>
</html>
